﻿Shader "Level4/SimpleHeatDistortion" {
	Properties {
		_BumpMap ("BumpMap", 2D) = "white" {}
		_BumpAmount("Bump Amount",float) = 0
	}
	
	CGINCLUDE
	#include "UnityCG.cginc"
	sampler _BumpMap;
	float _BumpAmount;
	sampler2D _GrabTexture;
	
	struct v2f{
		float4 pos:POSITION;
		float4 uvGrab:TEXCOORD;
		float2 uv:TEXCOORD1;
	};
	v2f vert(appdata_base i){
		v2f o;
		o.pos = mul(UNITY_MATRIX_MVP,i.vertex);
		o.uvGrab = ComputeGrabScreenPos(i.vertex);
		o.uv = i.texcoord;
		return o;
	}
	
	float4 frag(v2f i):COLOR{
		float3 bump = UnpackNormal(tex2D(_BumpMap,half2(i.uv.x,i.uv.y * _Time.x)));
		float4 screenColor = tex2Dproj(_GrabTexture,i.uvGrab.xyw + bump * _BumpAmount);
		return screenColor;
	}
	
	ENDCG
	
	SubShader {
		Tags { "RenderType"="Transparent" "Queue"="Transparent+100"}
		LOD 200
		GrabPass{}
		Pass{
			CGPROGRAM
			#pragma vertex vert
			#pragma fragment frag
			ENDCG
		}
	} 
	// FallBack "Diffuse"
}
